import { clamp, v2, v3 } from "cc";

export const GlobalConfig = {
    //#region -------------框架配置

    //#endregion

    //#region --------------当前游戏自定义
    /**2D->3D的缩放大小 */
    Scale2DTo3D: 1 / 30,

    //奖励
    Award: {
        Win: 0,
        Lose: 0,
        VideoAward: 500,    //视频奖励
        PathRate: 1,        //路段奖励
        //
        soldierA: 20,
        soldierB: 20,
        soldierC: 20,
        soldierD: 20,
        People: 20,
        boss: 100,
        //存活奖励
        survive: 10,
        winAwardStep: 0.1, //结算关卡加成
    },

    //角色成长属性比例 配置
    RolePropCfg: {
        // 属性 -default:初始 4.5, step每一级增加, max：上限
        moveSpd: { default: 4, step: [0.2, 0.15, 0.1, 0.05, 0.02], max: 10 },
        hp: { default: 15, step: [2, 1], },
        num: { default: 1, step: 1, max: 30 },
        // 花费
        moveSpdCost: { default: 200, step: 100 },
        hpCost: { default: 200, step: 100 },
        numRateCost: { default: 600, step: 300 },

        getHpStepByLv: (lv: number) => {
            const _cfg = GlobalConfig.RolePropCfg;
            let step = 1;
            if (lv <= 5) {
                step = _cfg.hp.step[0];
            } else {
                step = _cfg.hp.step[1];
            }
            return step;
        },
        // 
        getHpByLv: (lv: number) => {
            lv = clamp(lv, 1, lv);
            const _cfg = GlobalConfig.RolePropCfg;
            return (lv - 1) * _cfg.getHpStepByLv(lv) + _cfg.hp.default;
        },
        getHPCost: (lv: number) => {
            lv = clamp(lv, 1, lv);
            const _cfg = GlobalConfig.RolePropCfg.hpCost;
            return _cfg.default + _cfg.step * (lv - 1);
        },

        getMoveSpdStepBylv: (lv: number) => {
            const _cfg = GlobalConfig.RolePropCfg;
            let step = 1;
            if (lv <= 5) {
                step = _cfg.moveSpd.step[0];
            } else if (lv <= 20) {
                step = _cfg.moveSpd.step[1];
            } else if (lv <= 30) {
                step = _cfg.moveSpd.step[2];
            } else if (lv <= 40) {
                step = _cfg.moveSpd.step[3];
            } else {
                step = _cfg.moveSpd.step[4];
            }
            return step;
        },
        getMoveSpdByLv: (lv: number) => {
            lv = clamp(lv, 1, lv);
            const _cfg = GlobalConfig.RolePropCfg;
            return (lv - 1) * _cfg.getMoveSpdStepBylv(lv) + _cfg.moveSpd.default;
        },
        getMoveSpdCost: (lv: number) => {
            lv = clamp(lv, 1, lv);
            const _cfg = GlobalConfig.RolePropCfg.moveSpdCost;
            return _cfg.default + _cfg.step * (lv - 1);
        },

        getNumRateByLv: (lv: number) => {
            lv = clamp(lv, 1, lv);
            const _cfg = GlobalConfig.RolePropCfg;
            return (lv - 1) * _cfg.num.step + _cfg.num.default;
        },
        getNumRateCost: (lv: number) => {
            lv = clamp(lv, 1, lv);
            const _cfg = GlobalConfig.RolePropCfg.numRateCost;
            return _cfg.default + _cfg.step * (lv - 1);
        },
    },

    //显示2d碰撞
    isShow2dCollider: false,

    // 玩家 2d
    Player: {
        moveSpd: 5,
        protectedTime: 3,
        PassSpdRate: 2.5,  //通道加速
    },
    //僵尸 2d
    Zombie: {
        moveSpd: 5,
        atkDist: 120, //
        jumpTime: 0.3,
        recoverCd: 5,     //回复速度 s
        recoverRate: 0.2    //回复比例
    },

    /**敌人公共属性 2d */
    Enemy: {
        HP: 1,                  //基础值      
        hpStepLv: 1,            //每过指定关增加一次hp
        hpStep: 1,              //每次增加hp的数量
        hpMax: 20,              //hp上限

        deathTime: 0.7,         //变成僵尸的时间 s
        BossScale: 2,           //soldier变boss 的缩放大小
        atkLvRate: 0.3,         //正常关卡强化比例
        guideLvRate: 0.2,       //引导关卡强化比例
        ArmyBossAtk: 10,
    },

    /**士兵 2d*/
    Army: {
        //特种兵
        soldierA: {
            atkDist: 600,
            atkSpd: 2,
            atk: 3,
            bulletType: 'throughBullet2d',
            //子弹数量
            bulletNum: 15,
            //切换子弹cd
            bulletCd: 3,
        },
        //士兵
        soldierB: {
            atkDist: 400,
            atkSpd: 3,
            atk: 2,
            bulletType: 'normalBullet2d',
            //子弹数量
            bulletNum: 8,
            //切换子弹cd
            bulletCd: 4,
        },
        //警察
        soldierC: {
            atkDist: 500,
            atkSpd: 2,
            atk: 3,
            bulletType: 'normalBullet2d',
            //子弹数量
            bulletNum: 6,
            //切换子弹cd
            bulletCd: 5,
        },
        // 飞虎队
        soldierD: {
            atkDist: 400,
            atkSpd: 4,
            atk: 3,
            bulletType: 'normalBullet2d',
            //子弹数量
            bulletNum: 12,
            //切换子弹cd
            bulletCd: 2,
        },
    },

    /**平民 2D */
    People: {
        BossHp: 5,
        moveSpd: { min: 2, max: 4, lvRate: 0.1 },
        maxMoveSpd: 7.5,
        peopleA: {
            checkDist: 300,
        },
        peopleB: {
            checkDist: 400,
        },
        peopleC: {
            checkDist: 350,
        },
    },

    /**坦克 2D */
    Tank: {
        checkDist: 1500,
        atkSpd: 0.5,
        atk: 7,
        HP: 5,
    },

    //子弹 2d
    Bullet: {
        spd: 30,
    },

    //导弹2d
    Missile: {
        spd: 400, //像素单位
        atkRadius: 100, //像素单位
    },

    //地雷 2d
    Mine: {
        boomDelay: 0.5,   //s
        atkHpRate: 0.3,  //攻击=HP的百分比
        atkRadius: 75, //像素单位
    },

    //中间的障碍物2d
    Barrier: {
        addSpd: v2(6, 4),      //附加的速度
    },


    //相机位置+角度
    Camera: {
        initPos: v3(0, 5, -10.5),
        initRot: v3(-20, 180, 0),
        lvCamraPos: v3(0, 18, 18),
        lvCamraRot: v3(-45, 0, 0),
    }

    //#endregion
}
